﻿namespace CustomCommons
{

    public class ApiResult
    {
        public EnumCode Code { get; set; } = EnumCode.Fail;

        public string Message { get; set; } = "失败";

        public void Success(string message = "成功")
        {
            this.Code = EnumCode.Ok;
            this.Message = message;
        }

        public void Error(string message = "失败")
        {
            this.Code = EnumCode.Fail;
            this.Message = message;
        }
    }
    public class ApiResult<T> : ApiResult
    {
        public T Data { get; set; }

        public void Success(T data, string message = "成功")
        {
            this.Data = data;
            this.Code = EnumCode.Ok;
            this.Message = message;
        }
    }
}
